<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性的问题</title>
</head>
<body>
<div id="app">
    <!--  当变量内容发生变化的时候，计算属性无法确定是哪一个变量引起的变化  -->
    <div>
        姓氏：
        <input type="text" id="familyName" name="familyName" v-bind:value="familyName" v-on:input="onFamilyNameChange">
    </div>

    <div>
        名字：
        <input type="text" id="firstName" name="firstName" v-bind:value="firstName" v-on:input="onFirstNameChange">
    </div>

    <!--    <div>姓名：{{  familyName + " " + firstName }}</div>-->
    <div>姓名：{{ fullName }}</div>
</div>
<script type="module">
    import {createApp, ref, computed} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {

            let familyName = ref(null)
            let firstName = ref(null)

            function onFamilyNameChange() {
                let element = document.getElementById("familyName")
                familyName.value = element.value
            }

            function onFirstNameChange() {
                let element = document.getElementById("firstName")
                firstName.value = element.value
            }

            let fullName = computed(function () {
                return familyName.value + " " + firstName.value
            })


            return {
                familyName, firstName, onFamilyNameChange, onFirstNameChange, fullName
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>